//
//  SearchKeyView.swift
//  MyTest
//
//  Created by guanzhongwang on 2021/5/14.
//

import UIKit

class SearchKeyLabel: UIView {
    init(item:NewsSearchTextModel,index:Int) {
        super.init(frame: .zero)
        let label = UILabel()
        addSubview(label)
        label.textColor = B000_COLOR
        label.font = Font_Size_15
        label.text = item.key
        if item.isHot {
            let icon = UIImageView(image: UIImage(named: "hotkey")?.withRenderingMode(.alwaysTemplate))
            icon.tintColor = RED_COLOR
            addSubview(icon)
            icon.snp.makeConstraints({
                $0.width.height.equalTo(15)
                $0.right.equalToSuperview().inset(index % 2 == 0 ? 5:20)
                $0.centerY.equalToSuperview()
            })
            label.snp.makeConstraints({
                $0.left.equalTo(15)
                $0.top.bottom.equalTo(0)
                $0.right.equalTo(icon.snp.left).offset(-5)
            })
        }else{
            label.snp.makeConstraints({
                $0.right.top.bottom.equalTo(0)
                $0.left.equalTo(15)
            })
        }
        if index % 2 == 0 {
            let line = UIView()
            line.backgroundColor = Separator_COLOR
            addSubview(line)
            line.snp.makeConstraints({
                $0.width.equalTo(1)
                $0.top.right.bottom.equalTo(0)
            })
        }
    }
    required init?(coder: NSCoder) {
        fatalError()
    }
}
struct NewsSearchTextModel {
    var key:String = ""
    var isHot:Bool = false
}
